﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using InstaMe.Utils;
using InstaMe.Source.Model;

namespace InstaMe
{
    public class DiaryItemDataTemplateSelector : DataTemplateSelector
    {
        public DataTemplate Text
        {
            get;
            set;
        }

        public DataTemplate Photo
        {
            get;
            set;
        }

        public DataTemplate Audio
        {
            get;
            set;
        }

        public DataTemplate Video
        {
            get;
            set;
        }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            DiaryItem iDiaryItem = item as DiaryItem;
            if (iDiaryItem != null)
            {
                if (iDiaryItem.getType() == DiaryItem.TYPE_TEXT)
                {
                    return Text;
                }
                else if (iDiaryItem.getType() == DiaryItem.TYPE_PHOTO)
                {
                    return Photo;
                }
                else if (iDiaryItem.getType() == DiaryItem.TYPE_AUDIO)
                {
                    return Audio;
                }
                else if (iDiaryItem.getType() == DiaryItem.TYPE_VIDEO)
                {
                    return Video;
                }
            }

            return base.SelectTemplate(item, container);
        }
    }
}
